/**
 * Created by Administrator on 2017/9/6.
 */
$(function(){
    var index = 0;
    var bgcolor = ['#4085d2', '#fdeeeb', '#1B4046', '#D7DEE4', '#0AA9E0', '#D8DDE3', '#0C1222']
   function autoNext(){
       $lis = $("#pic li");
       if (index>=$lis.length){
           index = 0;
       }
       $lis.hide();
       $lis.eq(index).show(200);
       $('#box').css('backgroundColor',bgcolor[index]);

       $("#nav li").removeClass('navnow');
       $("#nav li").eq(index).addClass('navnow');
       index++;

   }
    autoNext();
   var t = setInterval(autoNext,3000);
    $("#pic li").hover(function(){
        clearInterval(t);
    },function(){
        t = setInterval(autoNext,3000)
    });
    $("#nav li").each(function(i){
       $(this).click([i],function(e){
          index = e.data[0];
           autoNext();
           clearInterval(t);
           t = setInterval(autoNext,3000);
       });
    })
});